#include "tailwgt.h"
#include <QVBoxLayout>
#include <QHBoxLayout>


tailWgt::tailWgt(QWidget *parent)
    : QWidget{parent}
{
    this->setFixedSize(1080,70);//设置窗口大小
    //    this->setStyleSheet("background-color:green");
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_StyledBackground);


    //创建对象
    stopBtn_ = new QPushButton(this);
    volumBtn_ = new QPushButton(this);
    curTime_ = new QLabel(this);
    allTime_ = new QLabel(this);
    volumSlider_ = new QSlider(Qt::Horizontal,this);
    playerSlider_ = new QSlider(Qt::Horizontal,this);


    stopBtn_->setObjectName("stopBtn1_");
    volumBtn_->setObjectName("volumBtn_");
    volumSlider_->setObjectName("volumSlider_");
    playerSlider_->setObjectName("playerSlider_");

    connect(stopBtn_,&QPushButton::clicked,this,[this](){
        if(isPuase_)
        {
            //贴图
            this->stopBtn_->setStyleSheet("QPushButton#stopBtn1_{image:url(:/titlebar/zating.png)}");
        }
        else
        {

            //贴图
            this->stopBtn_->setStyleSheet("QPushButton#stopBtn1_{image:url(:/titlebar/bofang.png)}");
        }
        isPuase_ = !isPuase_ ;

    });


    //    volumSlider_->setStyleSheet("  \
    //         QSlider::add-page:Horizontal\
    //         {     \
    //            background-color: rgb(87, 97, 106);\
    //            height:4px;\
    //         }\
    //         QSlider::sub-page:Horizontal \
    //        {\
    //            background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(231,80,229, 255), stop:1 rgba(7,208,255, 255));\
    //            height:4px;\
    //         }\
    //        QSlider::groove:Horizontal \
    //        {\
    //            background:transparent;\
    //            height:6px;\
    //        }\
    //        QSlider::handle:Horizontal \
    //        {\
    //            height: 30px;\
    //            width:8px;\
    //            border-image: url(:/images/ic_music_thumb.png);\
    //            margin: -8 0px; \
    //        }\
    //        ");

    //    playerSlider_->setStyleSheet("  \
    //                                 QSlider::add-page:Horizontal\
    //                                 {     \
    //                                    background-color: rgb(87, 97, 106);\
    //                                    height:4px;\
    //                                 }\
    //                                 QSlider::sub-page:Horizontal \
    //                                {\
    //                                    background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(231,80,229, 255), stop:1 rgba(7,208,255, 255));\
    //                                    height:4px;\
    //                                 }\
    //                                QSlider::groove:Horizontal \
    //                                {\
    //                                    background:transparent;\
    //                                    height:6px;\
    //                                }\
    //                                QSlider::handle:Horizontal \
    //                                {\
    //                                    height: 30px;\
    //                                    width:8px;\
    //                                    border-image: url(:/images/ic_music_thumb.png);\
    //                                    margin: -8 0px; \
    //                                }\
    //                                ");


    //    volumSlider_->setStyleSheet("QSlider::groove:horizontal "
    //                                "{ background: #999999; height: 8px; margin: 0 10px; border-radius: 4px; } "
    //                                "QSlider::handle:horizontal "
    //                                "{ background: #ffffff; border: 1px solid #999999; width: 16px; margin: -7px 0; border-radius: 10px; }");

    //    playerSlider_->setStyleSheet("QSlider::groove:horizontal { background: #999999; height: 8px; margin: 0 10px; border-radius: 4px; } "
    //                           "QSlider::handle:horizontal { background: #ffffff; border: 1px solid #999999; width: 16px; margin: -7px 0; border-radius: 10px; }");


    // 首先，创建一个QFont对象并设置字体为“幼圆”
    QFont font("幼圆", 8); // 第二个参数是字体大小

    // 然后，应用这个字体到你的标签
    curTime_->setFont(font);
    curTime_->setText(QString("当时间/"));

    curTime_->setStyleSheet("QLabel {"
                            "    border: transparent;"
                            //                                 "    background-color: transparent;"
                            "    background-repeat: no-repeat; "
                            "    border:1px groove transparent;"
                            "    border-radius:7px;"
                            "    padding:2px 4px;"
                            //                                 "    background-size: cover;"
                            //                                 "    color: rgb(255,255,255);"
                            "    color: rgb(0,0,0);"
                            "}"
                            );

    // 然后，应用这个字体到你的标签
    allTime_->setFont(font);
    allTime_->setText(QString("总时间"));

    allTime_->setStyleSheet("QLabel {"
                            "    border: transparent;"
                            //                                 "    background-color: transparent;"
                            "    background-repeat: no-repeat; "
                            "    border:1px groove transparent;"
                            "    border-radius:7px;"
                            "    padding:2px 4px;"
                            //                                 "    background-size: cover;"
                            //                                 "    color: rgb(255,255,255);"
                            "    color: rgb(0,0,0);"
                            "}"
                            );



    //设置控件大小
    stopBtn_ ->setFixedSize(30,30);
    volumBtn_ ->setFixedSize(30,30);
    curTime_ ->setFixedSize(70,30);
    allTime_ ->setFixedSize(70,30);
    volumSlider_ ->setFixedSize(350,20);
    playerSlider_->setFixedSize(150,20);

    //设置水平布局
    QHBoxLayout* hlayout_ = new QHBoxLayout(this);
    hlayout_->addWidget(stopBtn_);
    hlayout_->addWidget(volumSlider_);
    hlayout_->addStretch(1);//加弹簧
    hlayout_->addWidget(curTime_);
    hlayout_->addWidget(allTime_);
    hlayout_->addStretch(1);//加弹簧
    hlayout_->addWidget(volumBtn_);
    hlayout_->addWidget(playerSlider_);

    hlayout_->setContentsMargins(0,0,0,0);
    //设置布局
    this->setLayout(hlayout_);




}
